<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

class CreateLinksTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('links', function (Blueprint $table) {
            $table->increments('id');
            $table->string("link_name", 100)->comment("友链名称");
            $table->string("link_url", 150)->comment("链接地址");
            $table->string("link_content", 255)->comment("友链介绍");
            $table->tinyInteger("audit_status")->default(0)->comment("审核状态 0: 未审核  1：审核通过");
            $table->tinyInteger("is_enable")->default(0)->comment("是否启用 0: 未启用 1: 启用");
            $table->softDeletes()->comment('删除时间');
            $table->timestamp('created_at')->useCurrent()->comment('创建时间');
            $table->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'))->comment('更新时间');
        });
        DB::statement("ALTER TABLE ". env("DB_PREFIX") ."links comment '友链表'");//表注释
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('links');
    }
}
